/*
 * Copyright 2005-2010 the original author or authors.
 * 
 *      http://www.derbysoft.com/
 *
 * Project demo
 */
package com.zhisheng.core.dao;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.hibernate.Criteria;

import com.zhisheng.core.page.Page;


/**
 * @author qzhou
 * @since 2008-6-29
 * 
 */
public interface GenericDAO<T, ID extends Serializable> {
	
	T findById(ID id);
	
	T loadById(ID id);

    List<T> findAll();
    
    @SuppressWarnings("unchecked")
	List findByHql(String hql);

    void save(Object entity);

    void update(Object entity);
    
    void delete(Object entity);

    @SuppressWarnings("unchecked")
    Page findByPage(Page page, Class c);
    
    void delete(String id);
    
    @SuppressWarnings("unchecked")
	void delete(Class c, Serializable id);
    
	<E> List<E> findAll(Class<E> c);   
	  
	Page findPageByCriteria(final Criteria criteria, Page page);
    
	Page findPageByHql(String hql, Map<String, Object> parameters, Page page);
    /**
	 * @param resourceId
	 * @return
	 */
	<S> S findEntityById(Serializable resourceId, Class<S> c);
	
	void saveOrUpdate(Object o);
	
	void saveOrUpdateAll(List<T> list);
	
	Object findByQueryUniqueResult(String hql,Object values[]);

	<E> List<E> findByCondition(final String queryString, final Object condition);

	<E> List<E> findByCondition(final String queryString, final Object... conditions);
}
